<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文件编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>
<div class="layui-form" lay-filter="fileManagement-edit-form-list" id="fileManagement-edit-form-list" style="padding: 0 18px 0 0;">
    <div class="layui-form-item" style="padding-top: 15px">
        <label class="layui-form-label">文件名称</label>
        <div class="layui-input-inline">
            <input type="text" name="fileName" maxlength="80"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item alias layui-hide">
        <label class="layui-form-label">映射文件别名</label>
        <div class="layui-input-inline">
            <input type="text" name="alias"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">文件密级</label>
        <div class="layui-input-inline">
            <select name="fileSecretLevel" lay-verify="required">
                <#list fileSecretList as inNode>
                    <option value="${inNode.key}">${inNode.fileSecret}</option>
                </#list>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">文件摘要</label>
        <div class="layui-input-inline">
            <textarea name="fileKeywords" maxlength="80" style="width: 400px; height: 150px;" autocomplete="off" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">大小</label>
        <div class="layui-input-inline">
            <span class="fileSize" style="line-height: 38px"></span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上传人</label>
        <div class="layui-input-inline">
            <span class="uploadPersonName" style="line-height: 38px"></span>
        </div>
    </div>
    <div class="layui-form-item" style="margin-bottom: 0">
        <label class="layui-form-label">上传时间</label>
        <div class="layui-input-inline">
            <span class="uploadDate" style="line-height: 38px"></span>
        </div>
    </div>
    <div class="layui-form-item orderNumber layui-hide">
        <label class="layui-form-label">排序编号</label>
        <div class="layui-input-inline">
            <input type="text" name="orderNumber" lay-verify="numbers" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="fileManagement-edit-form-submit" id="fileManagement-edit-form-submit">
    </div>
</div>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>

    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','common','upload','jquery','commons','form','setter'], function () {
        var upload = layui.upload,$ = layui.jquery,commons = layui.commons,form=layui.form,setter=layui.setter;
        var  fileId='${fileId}';//树id
        form.verify({
            numbers: function(value, item){
                if(!value){
                    return false;
                }
                if( !(/^\S{0,4}$/.test(value))){
                    return '排序编号不能超过4位';
                }
                if(isNaN(value,item)){
                    return '排序编号为纯数字';
                }
            }
        });
        form.render();
        $.ajax({
            url: serverPath.systemPath + setter.sysLinkPath + "fileManagement/getFile",
            type: "post",
            dataType: 'json',
            data: {fileId:fileId},
            success: function (res) {
                if(res.code=='0'){
                    if(res.data.parentType=='2'){
                        $('#fileManagement-edit-form-list .alias.layui-hide').removeClass('layui-hide');
                        $('#fileManagement-edit-form-list .orderNumber.layui-hide').removeClass('layui-hide');
                    }
                    $('#fileManagement-edit-form-list input[name="fileName"]').val(res.data.fileName);
                    $('#fileManagement-edit-form-list textarea[name="fileKeywords"]').val(res.data.fileKeywords);
                    $('#fileManagement-edit-form-list span.fileSize').html(res.data.fileSize);
                    $('#fileManagement-edit-form-list span.uploadPersonName').html(res.data.uploadPersonName);
                    $('#fileManagement-edit-form-list span.uploadDate').html(component.timeData(res.data.uploadDate));
                    $('#fileManagement-edit-form-list select[name="fileSecretLevel"]').val(res.data.fileSecretLevel);
                    $('#fileManagement-edit-form-list input[name="orderNumber"]').val(res.data.orderNumber);
                    $('#fileManagement-edit-form-list input[name="alias"]').val(res.data.alias);
                    if(res.data.parentType=='2'){
                        $('#fileManagement-edit-form-list input[name="fileName"]').attr('disabled','disabled');
                        $('#fileManagement-edit-form-list input[name="fileName"]').addClass('layui-disabled');
                        $('#fileManagement-edit-form-list select[name="fileSecretLevel"]').attr('disabled','disabled');
                    }
                    form.render();
                }
            }
        });

    });
</script>
</body>
</html>